/**
 * Cider
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.xunk.common.core.enums;

import org.apache.commons.collections4.map.CaseInsensitiveMap;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 杨文栋
 * @version DeviceEnum.java, v 0.1 2021-03-17 18:41 杨文栋 Exp $$
 */
public enum SupplierEnum {
    /**
     * iphone
     */
    RUYING("ruying"),

    /**
     * 曼顿
     */
    MANDUN("mandun"),

    /**
     * 移康
     */
    YIKANG("yikang"),
    /**
     * 安科瑞
     */
    ACREL("acrel"),
    /**
     * 狄耐克
     */
    DNAKE("dnake"),
    /**
     * 智家优家
     */
    UPLUS("uplus"),

    UNKNOWN("unknown");

    /**
     * 设备名称
     */
    String supplierName;


    SupplierEnum(String supplierName) {
        this.supplierName = supplierName;
    }

    private static final Map<String, SupplierEnum> SUPPLIER_NAME_ENUM_MAP = Arrays.stream(SupplierEnum.values()).collect(Collectors.toMap(SupplierEnum::getSupplierName, Function.identity(), (a, b) -> a, CaseInsensitiveMap::new));

    public static SupplierEnum parseSupplierEnum(String supplierName) {
        return SUPPLIER_NAME_ENUM_MAP.getOrDefault(supplierName, UNKNOWN);
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
}
